#include <iostream>

using namespace std;


int l, r;
int c = 0;

void count2(int x)
{
    while (x)
    {
        if (x % 10 == 2) c ++;
        x /= 10;
    }
}

int main()
{
    cin >> l >> r;
    for (int i = l; i <= r; i++)
    {
        count2(i);
    }
    cout << c << endl;
    return 0;
}